<?php $this->pageHeader('Rediger medlem'); ?>

<p id="top_right_links">
    <a href="<?php echo $this->url(array('module' => 'admin', 'controller' => 'member', 'action' => 'courses', 'id' => $this->memberId), null, true); ?>" class="button"><img src="<?php echo $this->imageLink('images/icons/pencil.png'); ?>" />Rediger kurs/kompetanse</a>
    <a href="<?php echo $this->url(array('action' => 'delete', 'id' => $this->memberId)); ?>" class="button negative"><img src="<?php echo $this->imageLink('images/icons/delete.png'); ?>" />Marker som inaktiv</a>
</p>
    
<?php

echo $this->flashMessage()->renderMessages();

if($this->personaliaMessage) {
    echo $this->personaliaMessage;
} else if($this->phoneMessage) {
    echo $this->phoneMessage;
} else if($this->emailMessage) {
    echo $this->emailMessage;
} else if($this->permanentPassiveMessage) {
    echo $this->permanentPassiveMessage;
}

?>

<div>
	<h2>Personalia</h2>
<?php
	$this->personaliaForm->setMethod('post');
	$this->personaliaForm->setAction($this->url());
	echo $this->personaliaForm;
?>
</div>
<p>&nbsp;</p>

<div>
    <h2>Kommentar</h2>
    <?php
    $this->commentForm->setMethod('post');
    $this->commentForm->setAction($this->url());
    echo $this->commentForm;
    ?>
</div>
<p>&nbsp;</p>

<div>
	<h2>Telefonnummer</h2>
	<table>
		<tr>
			<th>Telefonnummer</th>
            <th>Type</th>
            <th>&nbsp;</th>
		</tr>
		<?php foreach($this->member->Phonenumbers as $phonenumber) { ?>
		<tr>
			<td><?php echo $phonenumber->number; ?></td>
			<td><?php echo $phonenumber->Phonetype->name; ?></td>
			<td>
				<a href="<?php echo $this->url(array('action' => 'remove-phone', 'id' => $phonenumber->id)); ?>">
					Slett
				</a>
			</td>
		</tr>
		<?php } ?>
	</table>

<p>&nbsp;</p>

<?php
	$this->phoneForm->setMethod('post');
	$this->phoneForm->setAction($this->url());
	echo $this->phoneForm;
?>
</div>

<p>&nbsp;</p>

<div>
	<h2>Epost</h2>

	<table>
		<tr>
			<th>Adresse</th>
			<th>&nbsp;</th>
		</tr>
		<?php foreach($this->member->emails as $email) { ?>
		<?php $isMainEmail = (bool)$email->is_main; ?>
		<tr>
			<td><?php echo $this->escape($email->address); ?><?php if ($isMainEmail) echo '*'; ?></td>
			<td>
		<?php if (!$isMainEmail) : ?>
				<a href="<?php echo $this->url(array('action' => 'remove-email', 'id' => $email->id)); ?>">Slett</a>
				 | <a href="<?php echo $this->url(array('action' => 'set-main-email', 'id' => $email->id)); ?>">Hoved</a>
		<?php endif; ?>
			</td>

		</tr>
		<?php } ?>
	</table>

<p>&nbsp;</p>

<?php
	$this->emailForm->setMethod('post');
	$this->emailForm->setAction($this->url());
	echo $this->emailForm;
?>

</div>

<p>&nbsp;</p>

<div>
	<h2>Permanent passiv</h2>
	<?php if ($this->isPassive) : ?>
	Medlemmet er satt som permanent passiv.<br />
	Kommentar til permanent passivmelding: '<?php echo $this->escape($this->member->getPermanentPassiveMessage()->comment); ?>'
	<?php endif; ?>

	<p>&nbsp;</p>
    
<?php
    $this->permanentPassiveForm->setMethod('post');
    $this->permanentPassiveForm->setAction($this->url());
    echo $this->permanentPassiveForm;
?>
</div>
